public class ITicketRunnable implements Runnable {
    // 总票数 50
    private int num = 50;
  
    @Override
    public void run() {
      while (true) {
        if (num <= 0) {
          break;
        }
  
        String name = Thread.currentThread().getName();
        System.out.println(name + "正在卖票，第" + num + "张票。");
        // 每隔50ms销售一张票
        num--;
        try {
          Thread.sleep(50);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }